<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class home extends CI_Controller 
{
	function __construct()
	{
		parent::__construct();
		$this->load->model('home_model','home');

	}
	
	function index($start=0)
	{
		$data['title'] = "Mua bán rao vặt" ;
		//pagging
		$data['start'] = $start = $this->uri->segment(3) ; 
		$config['base_url'] = base_url().'mua-ban/rao-vat/';  
		$data['num'] = $this->home->count_all();
		$config['total_rows'] = $data['num'];
		$config['per_page'] = 40;
		$config['uri_segment'] = 3;
		$config['num_links'] = 10 ;
		$this->pagination->initialize($config);   
		$data['pagination'] = $this->pagination->create_links();
		//get data
		$data['list'] = $this->home->get_all($config['per_page'], $start);
		$data['page'] = 'home' ;
		$this->load->view('html/skin',$data) ;
	}
	
	function category()
	{
		$data['title'] = '';
		$class_id = (int)$this->uri->segment(3);
		
		$data['start'] = (int) $this->uri->segment(4) ; 
		$config['base_url'] = base_url().'home/category/'.$class_id;  
		$data['num'] = $this->home->count_all_category($class_id);
		$config['total_rows'] = $data['num'];
		$config['per_page'] = 25 ;
		$config['uri_segment'] = 4 ;
		$config['num_links'] = 3 ;
		$this->pagination->initialize($config);   
		$data['pagination'] = $this->pagination->create_links();
		
		//get data
		$data['list'] = $this->home->get_all_category($class_id, $config['per_page'], $data['start']);
		$data['page'] = 'category' ;
		$this->load->view('html/skin',$data) ;
	}
	
	function detail()
	{
		$data['title'] = "Chi tiết rao vặt" ;
		$id = (int)$this->uri->segment(3);
		$data['rs'] = $this->home->get_detail($id);
		
		$data['list_cate'] = $this->home->get_all_category($data['rs']->class_id, 10, 0);
		$data['list_news'] = $this->home->get_news_by_user($data['rs']->member_id, 10, 0);
		
		$data['page'] = 'detail' ;
		$this->load->view('html/skin',$data) ;
	}
	
}

?>